home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / abstyles / docmac.tex (.txt) < prev    next >
LaTeX Document  |  1991-08-12  |  8KB  |  210 lines

  1. \chardef\escape=0
  2. \chardef\letter=11
  3. \chardef\other=12
  4. %\chardef\active=13              % is defined in Plain already
  5. \chardef\atcode=\catcode`\@
  6. \chardef\uscode=\catcode`\_
  7. \catcode`\@=\letter
  8. \catcode`\_=\letter
  9. \font\tentex=cmtex10            % typewriter extended ASCII 10pt
  10. \let\ttex=\tentex               % only for PLAIN with base size 10pt
  11. \def\setup_verbatim{%
  12.    \def\do##1{\catcode`##1\other}\dospecials
  13.    \parskip\z@skip \parindent\z@
  14.    \obeylines \obeyspaces \obeytabs \frenchspacing
  15.    \ttex
  16. \let\tab=\space
  17. \begingroup
  18.    \catcode`\^^I=\active%       % Attention: no tabs!
  19.    \gdef\obeytabs{\catcode`\^^I=\active\def^^I{\tab}}
  20.    \global\let^^I=\tab%         % if an active tab appears in a \write
  21. \endgroup
  22. \let\origvert=|
  23. \chardef\vbar=`\|
  24. \catcode`\|=\active
  25. \def|{%
  26.    \leavevmode
  27.    \hbox\bgroup
  28.       \let\par\space \setup_verbatim
  29.       \let|\egroup
  30. \newif\if@print
  31. \def\beginprog{%
  32.    \endgraf
  33.    \bigbreak
  34.    \begingroup
  35.       \setup_verbatim \catcode`\|\other
  36.       \@printtrue
  37.       \ignore_rest_line
  38. \let\end_verbatim=\endgroup             % internal command !
  39. \begingroup
  40.    \obeylines%          % ^^M is active! ==> every line must end with %
  41.    \gdef\ignore_rest_line#1^^M{\set_next_line}%
  42.    \gdef\set_next_line#1^^M{\do_set{#1}}%
  43. \endgroup
  44. \def\do_set#1{%
  45.    \endgraf
  46.    \check_print{#1}%
  47.    \if@print  \indent \print_char#1\end_line\end_line
  48.    \else  \let\set_next_line\end_verbatim
  49.    \fi
  50.    \set_next_line
  51. \let\end_line=\relax
  52. \begingroup
  53. \obeyspaces\obeytabs
  54. \gdef\check_print#1{\cut_at_tab#1^^I\end_line}
  55. \gdef\cut_at_tab#1^^I#2\end_line{\check_first_part#1 \end_line}% blank !
  56. \gdef\check_first_part#1 #2\end_line{\do_check{#1}}
  57. \endgroup
  58. \def\do_check#1{%
  59.    \def\@line{#1}%
  60.    \ifx \@line\@endverbatim  \@printfalse
  61.    \fi
  62. {\catcode`\|=\escape  \catcode`\\=\other % | is temporary escape char
  63.    |gdef|@endverbatim{\endprog}          % sample line
  64. }                                        % here \endgroup can't be used
  65. \newcount\char_count  \char_count\@ne
  66. \def\print_char#1#2\end_line{%
  67.    \print_first_char{#1}%
  68.    \print_rest_of_line{#2}%
  69. {\obeytabs\gdef\@tab{^^I}}
  70. \def\print_first_char#1{%
  71.    \def\@char{#1}%
  72.    \advance \char_count\@ne
  73.    \ifx \@char\@tab  \print_tab
  74.    \else  \@char
  75.    \fi
  76. \newcount\count_mod_viii
  77. \def\mod_viii#1{%
  78.    \count@ #1\relax  \count_mod_viii\count@
  79.    \divide \count@ 8\relax
  80.    \multiply \count@ 8\relax
  81.    \advance \count_mod_viii -\count@
  82. \def\print_tab{%
  83.    \loop  \space \mod_viii\char_count
  84.       \ifnum \count_mod_viii>\z@
  85.          \advance \char_count\@ne
  86.    \repeat
  87. \def\print_rest_of_line#1{%
  88.    \def\@line{#1}%
  89.    \ifx \@line\empty  \char_count\@ne
  90.         \def\next##1\end_line{\relax}%
  91.    \else  \let\next\print_char
  92.    \fi
  93.    \next#1\end_line
  94. \newcount\sectno  \sectno=\@ne
  95. \def\chap#1.{%
  96.    \mark{\number\sectno}
  97.    \endgraf
  98.    \vfill\eject
  99.    \def\rhead{\uppercase{\ignorespaces#1}} % define running headline
  100.    \message{*\number\sectno} % progress report
  101.    \let\Z=\let % now you can \send the control sequence \Z
  102.    \edef\next{\write\cont{\Z{#1}{\number\sectno}{\the\pageno}}}\next % to contents file
  103.    \noindent {\bf \number\sectno.\quad #1.}%
  104.    \advance \sectno\@ne
  105.    \endgraf
  106.    \medskip  \nobreak
  107.    \everypar{%
  108.       \setbox0\lastbox
  109.       \global\everypar{}%
  110.       }%
  111. \def\sect{%
  112.    \mark{\number\sectno}
  113.    \endgraf
  114.    \vskip 2pc plus 1pc minus 6dd  \goodbreak
  115.    \noindent {\bf \number\sectno.}\advance \sectno\@ne
  116.    \quad \ignorespaces
  117. \parskip 0pt % no stretch between paragraphs
  118. \parindent 1em % for paragraphs and for the first line of Pascal text
  119. \font\eightrm=cmr8
  120. \font\sc=cmcsc10 % this IS a caps-and-small-caps font!
  121. \let\mainfont=\tenrm
  122. \font\titlefont=cmr7 scaled\magstep4 % title on the contents page
  123. \font\ttitlefont=cmtt10 scaled\magstep2 % typewriter type in title
  124. %\font\tentex=cmtex10 % TeX extended character set (used in strings)
  125.         % already defined above
  126. \fontdimen7\tentex=0pt % no extra space after punctuation
  127. \def\\#1{\hbox{\it#1\/\kern.05em}} % italic type for identifiers
  128. \def\|#1{\hbox{$#1$}} % one-letter identifiers look a bit better this way
  129. \def\{\hbox{\bf#1\/}} % boldface type for reserved words
  130. \def\.#1{\hbox{\tentex % typewriter type for strings
  131.   \let\\=\BS % backslash in a string
  132.   \let\'=\RQ % right quote in a string
  133.   \let\`=\LQ % left quote in a string
  134.   \let\{=\LB % left brace in a string
  135.   \let\}=\RB % right brace in a string
  136.   \let\~=\TL % tilde in a string
  137.   \let\ =\SP % space in a string
  138.   \let\_=\UL % underline in a string
  139.   \let\&=\AM % ampersand in a string
  140.   #1}}
  141. \def\#{\hbox{\tt\char`\#}} % parameter sign
  142. \def\${\hbox{\tt\char`\$}} % dollar sign
  143. \def\%{\hbox{\tt\char`\%}} % percent sign
  144. \def\^{\ifmmode\mathchar"222 \else\char`^ \fi} % pointer or hat
  145. % circumflex accents can be obtained from \^^D instead of \^
  146. \def\AT!{@} % at sign for control text
  147. \chardef\AM=`\& % ampersand character in a string
  148. \chardef\BS=`\\ % backslash in a string
  149. \chardef\LB=`\{ % left brace in a string
  150. \def\LQ{{\tt\char'22}} % left quote in a string
  151. \chardef\RB=`\} % right brace in a string
  152. \def\RQ{{\tt\char'23}} % right quote in a string
  153. \def\SP{{\tt\char`\ }} % (visible) space in a string
  154. \chardef\TL=`\~ % tilde in a string
  155. \chardef\UL=`\_ % underline character in a string
  156. \newdimen\pagewidth \pagewidth=6.5in % the width of each page
  157. \newdimen\pageheight \pageheight=8.7in % the height of each page
  158. \newdimen\fullpageheight \fullpageheight=9in % page height including headlines
  159. \newdimen\pageshift \pageshift=0in % shift righthand pages wrt lefthand ones
  160. \def\magnify#1{\mag=#1\pagewidth=6.5truein\pageheight=8.7truein
  161.   \fullpageheight=9truein\setpage}
  162. \def\setpage{\hsize\pagewidth\vsize\pageheight} % use after changing page size
  163. \def\lheader{\mainfont\the\pageno\eightrm\qquad\rhead\hfill\title\qquad
  164.   \tensy x\mainfont\topmark} % top line on left-hand pages
  165. \def\rheader{\tensy x\mainfont\topmark\eightrm\qquad\title\hfill\rhead
  166.   \qquad\mainfont\the\pageno} % top line on right-hand pages
  167. \def\page{\box255 }
  168. \def\normaloutput#1#2#3{\ifodd\pageno\hoffset=\pageshift\fi
  169.   \shipout\vbox{
  170.     \vbox to\fullpageheight{
  171.       \iftitle\global\titlefalse
  172.       \else\hbox to\pagewidth{\vbox to10pt{}\ifodd\pageno #3\else#2\fi}\fi
  173.       \vfill#1}} % parameter #1 is the page itself
  174.   \global\advance\pageno by1}
  175. \def\rhead{\.{DOCMAC} OUTPUT} % this running head is reset by starred sections
  176. \def\title{} % an optional title can be set by the user
  177. \def\contentspagenumber{0} % default page number for table of contents
  178. \newif\iftitle
  179. \def\topofcontents{\centerline{\titlefont\title}
  180.   \vfill} % this material will start the table of contents page
  181. \def\botofcontents{\vfill} % this material will end the table of contents page
  182. \def\contentsfile{\jobname.toc} % file that gets table of contents info
  183. \def\readcontents{\expandafter\input \contentsfile}
  184. \newwrite\cont
  185. \output{\setbox0=\page % the first page is garbage
  186.   \openout\cont=\contentsfile
  187.   \global\output{\normaloutput\page\lheader\rheader}}
  188. \setpage
  189. \vbox to \vsize{} % the first \topmark won't be null
  190. \def\con{%
  191.   \write\cont{} % ensure that the contents file isn't empty
  192.   \closeout\cont % the contents information has been fully gathered
  193.   \par\vfill\eject % finish the preceding page
  194.    \rightskip 0pt \hyphenpenalty 50 \tolerance 200
  195.   \setpage
  196.   \output{\normaloutput\page\lheader\rheader}
  197.   \titletrue % prepare to output the table of contents
  198.   \pageno=\contentspagenumber \def\rhead{TABLE OF CONTENTS}
  199.   \message{Table of contents:}
  200.   \topofcontents
  201.   \line{\hfil Section\hbox to3em{\hss Page}}
  202.   \def\Z##1##2##3{\line{\ignorespaces##1
  203.     \leaders\hbox to .5em{.\hfil}\hfil\ ##2\hbox to3em{\hss##3}}}
  204.   \readcontents\relax % read the contents info
  205.   \botofcontents \end} % print the contents page(s) and terminate
  206. \let\contentspage=\con
  207. \catcode`\@=\atcode
  208. \catcode`\_=\uscode
  209. \endinput
  210.